import {ref} from 'vue'
import { apiSiteList, apiPlaList, apiEqupList, apiPLCSelList, apiCapSelList,apiDataTypeSelList } from '@/api/cost'

export default function () {
  let siteOptions = ref([]) // 站点列表
  let plaOptions = ref([]) // 构筑物列表
  let equpOptions = ref([]) // 设备或仪表列表
  let capOptions = ref([]) // 数据点列表
  let PLCOptions = ref([]) // PLC列表
  let dataTypeOptions = ref([]) // 数据类型列表

  // 获取站点 下拉列表
  const getSiteList = async() => {
    const res = await apiSiteList()
        
    siteOptions.value = res
  }
  // 获取数据类型 下拉列表
  const getDataTypeSelList = async() => {
    const res = await apiDataTypeSelList()
        
    dataTypeOptions.value = res
  }

  // 获取构筑物 下拉列表
  const getPlaList = async(sitCode) => {
    const res = await apiPlaList({sitCode})
        
    plaOptions.value = res
  }
  // 获取设备或仪表编码 下拉列表
  const getEqupList = async(sitCode,plaCode) => {
    const res = await apiEqupList({
      sitCode,
      plaCode
    })
        
    equpOptions.value = res
  }
  // 获取PLC 下拉列表
  const getPLCSelList = async(sitCode) => {
    
    const res = await apiPLCSelList({sitCode})
        
    PLCOptions.value = res
    console.log('hooks list');
  }
  // 获取数据点 下拉列表
  const getCapSelList = async(sitCode, plaCode) => {
    const res = await apiCapSelList({sitCode, plaCode})
        
    capOptions.value = res
  }

  return {
    siteOptions,
    plaOptions,
    equpOptions,
    PLCOptions,
    capOptions,
    dataTypeOptions,
    getDataTypeSelList,
    getSiteList,
    getPlaList,
    getEqupList,
    getPLCSelList,
    getCapSelList
  }
}